package com.uphone.edwards.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.uphone.edwards.R;

public class ContanctsAdapter extends MybaseAdapter<String>{
    private Context mContext;
    public ContanctsAdapter(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public View setView(int position, View converView, ViewGroup parent) {
        final ViewHolder holderView;
        if (converView == null) {
            converView = inflater.inflate(R.layout.item_contacts, null);
            holderView = new ViewHolder(converView);
            converView.setTag(holderView);
        } else {
            holderView = (ViewHolder) converView.getTag();
        }
        String item = getItem(position);

        holderView.llPhone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent dialIntent =  new Intent(Intent.ACTION_DIAL, Uri.parse("tel:18888888888"));//跳转到拨号界面，同时传递电话号码
                mContext.startActivity(dialIntent);
            }
        });
        holderView.tvPhone.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
        holderView.tvPhone.getPaint().setAntiAlias(true);//抗锯齿

        return converView;
    }
    class ViewHolder{
        private LinearLayout llPhone;
        private TextView tvPhone;
        public ViewHolder(View v){
            llPhone = v.findViewById(R.id.ll_phone);
            tvPhone = v.findViewById(R.id.tv_phone);
        }
    }
}
